using System;
using System.Data;
using System.Collections.Generic;
using System.Text;

using PickGold;
using PickGold.Database;

namespace PickGold.Entities.Table
{
    public class CExtendIpInfo : CExtendTable
    {
        //
        public const string ENTITY_NAME = "te_sys_ip_info";
        public const string ENTITY_ALIAS = "ip";
        //
        public const string ITEM_IP = "item_ip";
        public const string ITEM_MASK = "item_mask";
        public const string ITEM_AREA = "item_area";
        public const string ITEM_ADDRESS = "item_address";
        //
        private SExtendIpInfo _ = null;
        //
        public CExtendIpInfo() : base(ENTITY_NAME, ENTITY_ALIAS) { }
        public CExtendIpInfo(CDatabase db) : base(db, ENTITY_NAME, ENTITY_ALIAS) { }
        public CExtendIpInfo(string alias) : base(ENTITY_NAME, alias) { }
        public CExtendIpInfo(CDatabase db, string alias) : base(db, ENTITY_NAME, alias) { }
        //
        protected override void SetSchema()
        {
            this.SetSchema(new SExtendIpInfo());
        }
        protected void SetSchema(SExtendIpInfo s)
        {
            this._ = s;
            base.SetSchema(s);
        }
        //
        protected override void PreInitSchema()
        {
			base.PreInitSchema();
            this._DataTable.Columns.Add(ITEM_IP, typeof(long)).DefaultValue = this._.ItemIp;
            this._DataTable.Columns.Add(ITEM_MASK, typeof(long)).DefaultValue = this._.ItemMask;
            this._DataTable.Columns.Add(ITEM_AREA, typeof(string)).MaxLength = 50;
            this._DataTable.Columns.Add(ITEM_ADDRESS, typeof(string)).MaxLength = 256;
        }
        //
        protected override List<DataColumn> AddKeyColumn()
        {
            List<DataColumn> list = base.AddKeyColumn();
            list.Add(this._DataTable.Columns[ITEM_IP]);
            list.Add(this._DataTable.Columns[ITEM_MASK]);
            return list;
        }
        //
        #region Property
        //
        public long ItemIp
        {
            set
            {
                this._.ItemIp = value;
                this.SetValue(ITEM_IP, value);
            }
            get
            {
                return this._.ItemIp;
            }
        }
        //
        public long ItemMask
        {
            set
            {
                this._.ItemMask = value;
                this.SetValue(ITEM_MASK, value);
            }
            get
            {
                return this._.ItemMask;
            }
        }
        //
        public string ItemArea
        {
            set
            {
                this._.ItemArea = value;
                this.SetValue(ITEM_AREA, value);
            }
            get
            {
                return this._.ItemArea;
            }
        }
        //
        public string ItemAddress
        {
            set
            {
                this._.ItemAddress = value;
                this.SetValue(ITEM_ADDRESS, value);
            }
            get
            {
                return this._.ItemAddress;
            }
        }
        //
        #endregion
        //
        public override bool MoveTo(int position)
        {
            if (!base.MoveTo(position))
                return false;
            this._.ItemIp = this.GetValue<long>(ITEM_IP);
            this._.ItemMask = this.GetValue<long>(ITEM_MASK);
            this._.ItemArea = this.GetValue<string>(ITEM_AREA);
            this._.ItemAddress = this.GetValue<string>(ITEM_ADDRESS);
            return true;
        }
        //
    }
    //
    public class SExtendIpInfo : SExtendTable
    {
        //
        public long ItemIp = -1;
        public long ItemMask = -1;
        public string ItemArea = null;
        public string ItemAddress = null;
        //
    }
    //
}
//
